1 <table height="28" cellSpacing="0" cellPadding="0" width="100%" border="0">
2       <tr align=center>
3         <td
class="title" width="100%" height="17">
4         Danh m&#
7909;c tin tức: <b> <a href="./?act=news_category_m"><font color="#FFFFFF">Nh&#7853;p
5         M&#
7899;i</font></a><font color="#FFFFFF"></font></b></td>
6       </tr>
7     </table>
8 <?
9     
switch ($_GET['action'])
10     {
11         
case 'del' :
12             $id = $_GET[
'id'];
13             $result = mysql_query(
"select cat_id from news where cat_id='".$id."'",$con);
14             
if (mysql_num_rows($result)<=0) {
15                 $sql =
"delete from news_cat where id='".$id."'";
16                 @$result = mysql_query($sql,$con);
17                 
if ($result) echo "<p align=center class='err'>&#272;ã xóa thành công</p>";
18                 
else echo "<p align=center class='err'>Không th&#7875; xóa d&#7919; li&#7879;u</font></p>";
19             }
else {
20                 echo
"<p align=center class='err'>&#272;ang có s&#7843;n ph&#7849;m s&#7917; d&#7909;ng. nên b&#7841;n không th&#7875; xóa</p>";
21             }
22             
23             
break;
24     }
25 ?>
26
27 <?
28     
if (isset($_POST['ButDel'])) {
29         $cnt=
0;
30         
foreach ($_POST['chk'] as $id)
31         {
32             @$result = mysql_query(
"delete from news_cat where id='".$id."'",$con);
33             
if ($result) $cnt++;
34         }
35         echo
"<p align=center class='err'>&#272;ã xóa ".$cnt." ph&#7847;n t&#7917;</p>";
36     }
37 ?>
38 <?
39     $page = $_GET[
"page"];
40     $p=
0;
41     
if ($page!='') $p=$page;
42     $
where="1=1";
43     
if ($_REQUEST['cat']!='') $where="parent=".$_REQUEST['cat'];
44 ?>
45 <form method=
"POST" action="<? echo $_SERVER[PHP_SELF]; ?>" name="frmList">
46 <input type=hidden name=
"page" value="<? echo $page; ?>">
47 <?
48 function taotrang($sql,$link,$nitem,$itemcurrent)
49 {
global $con;
50     $ret=
"";
51     $result = mysql_query($sql, $con) or die(
'Error' . mysql_error());
52     $
value = mysql_fetch_array($result);
53     $plus = (($
value['cnt'] % $nitem)>0);
54     
for ($i=0;$i<($value[0] / $nitem) + plus;$i++)
55     {
56         
if ($i<>$itemcurrent) $ret .= "<a href=\"".$link.$i."\" class=\"lslink\">".($i+1)."</a> ";
57         
else $ret .= ($i+1)." ";
58     }
59     
return $ret;
60 }
61     $pageindex=taotrang(
"select count(*) from news_cat where $where","./?act=news_category"."&page=",$MAXPAGE,$page);
62 ?>
63
64
65 <table border=
"1" cellpadding="2" style="border-collapse: collapse" bordercolor="#C9C9C9" width="100%" id="AutoNumber1">
66   <tr>
67     <td align=center nowrap
class="title"><input type="checkbox" name="chkall" onclick="chkallClick(this);"></td>
68     <td nowrap
class="title">&nbsp;</td>
69     <td nowrap
class="title">&nbsp;</td>
70     <td align=
"center" nowrap class="title"><b>Tên danh muc</b></td>
71     <td align=
"center" nowrap class="title"><b>Thu&#7897;c danh m&#7909;c</b></td>
72     <td align=
"center" nowrap class="title"><b>Thu tu</b></td>
73     <td align=
"center" nowrap class="title"><b>Ngày</b></td>
74   </tr>
75   
76   <?
77                 $sql=
"select * from news_cat where $where order by thutu ";
78                 $result=mysql_query($sql,$con);
79                 $i=
0;
80                 
while(($row=mysql_fetch_array($result)))
81                 {
82                     $i++;
83                     
if ($i%2) $color="#d5d5d5"; else $color="#e5e5e5";
84                         
85                     
86   ?>
87   
88   <tr>
89     <td width=
"20" align="center" bgcolor="<? echo $color; ?>" class="smallfont">
90     <input type=
"checkbox" name="chk[]" value="<? echo $row['id']; ?>"></td>
91     <td width=
"20" bgcolor="<? echo $color; ?>" class="smallfont">
92     <a href=
"./?act=news_category_m&page=<? echo $_REQUEST['page']; ?>&id=<? echo $row['id']; ?>">S&#7917;a</a></td>
93     <td width=
"20" bgcolor="<? echo $color; ?>" class="smallfont">
94     <a onclick=
"return confirm('B&#7841;n có ch&#7855;c ch&#7855;n mu&#7889;n xoá ?');" href="./?act=news_category&page=<? echo $_REQUEST['page']; ?>&action=del&id=<? echo $row['id']; ?>">Xoá</a></td>
95     <td bgcolor=
"<? echo $color; ?>" class="smallfont"><? echo $row['name']; ?>&nbsp;</td>
96     <td bgcolor=
"<? echo $color; ?>" class="smallfont"><? echo $row['parent']; ?>&nbsp;</td>
97     <td width=
"80" bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['thutu']; ?>&nbsp;</td>
98     <td width=
"100" bgcolor="<? echo $color; ?>" class="smallfont"><? echo date('d/m/Y',strtotime($row['date'])); ?>&nbsp;</td>
99   </tr>
100   <?
101                 }
102   ?>
103 </table>
104 <input type=
"submit" value="Xóa Ch&#7885;n" name="ButDel" onclick="return confirm('B&#7841;n có ch&#7855;c ch&#7855;n mu&#7889;n xoá ?');" class="button" style="padding: 0">
105 <input type=
"hidden" name="act" value="news_category">
106 </form>
107 <script language=
"JavaScript">
108 function chkallClick(o) {
109     
var form = document.frmList;
110     
for (var i = 0; i < form.elements.length; i++) {
111         
if (form.elements[i].type == "checkbox" && form.elements[i].name!="chkall") {
112             form.elements[i].
checked = document.frmList.chkall.checked;
113         }
114     }
115 }
116 </script>



Full source code website bán hàng thương mại điện tử gần giống shopee 468.938 lượt xem

Gõ tìm kiếm nhanh...